set(TARGET_NAME SyyGather)

include_directories(${CMAKE_ROOT_DIR}/lib/datacenter)
include_directories(${CMAKE_ROOT_DIR}/lib/reg)
include_directories(${CMAKE_ROOT_DIR}/lib/modbus)

add_library(idevice STATIC
    idevice.cpp)

add_library(physicallinkmanager STATIC
    physicallinkmanager.cpp)

add_library(crc16 STATIC
    crc16.cpp)

add_library(string_match STATIC
    string_match.cpp)

add_library(json_util STATIC
    json_util.cpp)

add_library(util_tools STATIC
    util_tools.cpp)

add_library(base64 STATIC
    base64.cpp)

add_executable(${TARGET_NAME}
    main_data.cpp
    gather.cpp
    devicemanager.cpp
    sensormanager.cpp
    sensornode.cpp
    logger.cpp
    modulemanager.cpp)

find_library(zlog libzlog.so.1.2 PATHS ${PLATFORM_LINK_DIR} NO_DEFAULT_PATH)

if (${PLATFORM} MATCHES "powereuler")
    find_library(mqtt3as libpaho-mqtt3a.so.1 PATHS ${PLATFORM_LINK_DIR} NO_DEFAULT_PATH)
endif()

set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "/userdata/dgri/app/SyyGather/lib")

target_link_libraries(${TARGET_NAME}
                ${mqtt3as}
                ${zlog}
                physicallinkmanager
                idevice
                idatacenter
                icom
                json
                crc16
                util_tools
                string_match
                json_util
                ireg
                modbus-data)

install(TARGETS ${TARGET_NAME}
        DESTINATION .)

install(FILES ${mqtt3as} ${zlog}
    DESTINATION lib)